﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel;

namespace UniCT.LinkShareWpf.Interface
{
    [DataContract]
    public class TechnicalInfo : INotifyPropertyChanged
    {
        [DataMember]
        UInt32 megaByte;
        [DataMember]
        EnumVideoType videoType;
        [DataMember]
        EnumAudioSource aSource;
        [DataMember]
        EnumVideoSource vSource;
        
       
        public TechnicalInfo()
        {
            megaByte = 123;
            videoType = EnumVideoType.Mkv;
            aSource = EnumAudioSource.MP3;
            vSource = EnumVideoSource.DVDMux;
        }


        public override string ToString()
        {
            return string.Format("{0},{1},{2},{3}", megaByte, videoType, aSource, vSource);
        }

        public UInt32 MegaByte
        {
            get { return this.megaByte; }
            set
            {
                if (value != this.megaByte)
                {
                    this.megaByte= value;
                    this.OnPropertyChanged("MegaByte");
                }
            }
        }
        public EnumVideoType VideoType
        {
            get;
            set;
        }
        public EnumVideoSource VideoSource
        {
            get;
            set;
        }
        public EnumAudioSource AudioSource
        {
            get;
            set;
        }


        #region IDataErrorInfo Members

        public string Error
        {
            get { return null; }
        }

        public string this[string propName]
        {
            get
            {
                if (propName == "MegaByte")
                {
                    if (this.MegaByte < 0)
                    {
                        return "La dimensione in MegaByte deve essere maggiore di 0.";
                    }
                }
                return null;
            }
        }

        #endregion

        #region INotifyPropertyChanged Support

        protected void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null) this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }


        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }

    public enum EnumVideoType
    {
        Avi,
        Divx,
        Flv,
        Mkv,
        Mov,
        Mpeg,
        Mpeg4,
        Wmv
    }
    public enum EnumVideoSource
    {
        BDRip,
        CAM,
        DVDSCR,
        DVDRip,
        DVDMux,
        HDTV,
        R5,
        TC,
        TS,
        VHSSCR
    }
    public enum EnumAudioSource
    {
        AC3,
        DD,
        DTS,
        LD,
        MD,
        MP3
    }
}
